#include <stdio.h>
#include <string.h>
#include "lib/add.h"
#include <stdlib.h>
#include <iconv.h>


extern int Base64Decode(unsigned char *const aDest, const char *aSrc);
extern int Base64Encode(char *const aDest, const unsigned char* aSrc, int iLen);


void proc_info(char *eopBuf,int str_len)
{
    char aczBuf[4096*10];
    char aczTemp[100];
    int j = 0;
    char *p = eopBuf;
    memset(aczBuf, 0x00, sizeof(aczBuf));

    if(!strstr(eopBuf, "%"))
    {
        return;
    }

    for(; *eopBuf; )
    {
        if(*eopBuf == '%')
        {
            memset(aczTemp, 0x00, sizeof(aczTemp));
            strncpy(aczTemp, eopBuf+1, 2);
            aczBuf[j++]= (char)strtol(aczTemp, NULL, 16);
            eopBuf+=3;
        }
        else
        {
            aczBuf[j++]=*eopBuf++;
        }
    }

    strncpy(p, aczBuf,str_len);
}


int main(void)
{

#if 0
	int a = 1;
	int b = 2;
	int c = add_l(a , b);
	fprintf(stdout,"%d\n",c);

	char ch;
	char tmp[1024];
	memset(tmp,0x00,sizeof(tmp));
	int i = 0;
	while((ch = getchar()) != EOF)
	{
		tmp[i] = ch;
		i++;	
	}
	fprintf(stdout,"%s",tmp);

	char str1[] = "a|b|c|d|e";
	char str2[10];
	memset(str2,0x00,sizeof(str2));	
	getField(str1,"|",str2,3);
	printf("%s\n",str2);


	//iconv_t cd = iconv_open("gb18030","utf-8");
	iconv_t cd = iconv_open("GBK","UTF-8");
	//iconv_t cd = iconv_open("utf8","gb18030");
	if(cd == (iconv_t)-1)
	{
		printf("cd : 0\n");
		return -1;
	}
	char *s1 = "你好，中国";
	size_t s2_len = 100;
	char *s2 = malloc(sizeof(char) * s2_len);
	if(!s2)
	{
		printf("malloc error\n");
		return -1;
	}
	memset(s2,0x00,s2_len * sizeof(char));
	size_t s1_len = strlen(s1);
	printf("s1_len:%d\n",s1_len);
	size_t ret = iconv(cd,&s1,&s1_len,&s2,&s2_len);
	if(ret == (size_t)-1)
	{
		printf("iconv error\n");	
		return ret; 
	}	
	printf("s1:%s\n",s1);
	printf("s2:%s\n",s2);
	iconv_close(cd);

	struct timeval stamp;
	gettimeofday(&stamp,NULL);
		
	long milli = stamp.tv_sec * 1000L + stamp.tv_usec / 1000L;
	printf("%ld\n",milli);


	char ch;
	char tmp[4096];
	memset(tmp,0x00,sizeof(tmp));
	int i = 0;
	while((ch = getchar()) != EOF)
	{
		tmp[i] = ch;
		i++;	
	}
	printf("%s\n",tmp);

	proc_info(tmp,sizeof(tmp));
	printf("tmp = [%s]\n",tmp);

#endif

	int s = 012;
	printf("%d\n",s);


	return 0;
}

